﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using CSharpDesign.DAL;

namespace CSharpDesign.BLL
{
    public class ShangPinGuanLiService
    {
        SqlHelper data = new SqlHelper();

        public void DeleteShangPinGuanLi(string ID)
        {
            try
            {
                data.RunSql("delete  from ShangPin  where  SPID='" + ID + "'");
            }
            catch
            {

            }
        }

        public DataSet GetCodeBy(int iCount)
        {
            SqlHelper date = new SqlHelper();
            string strTop = "";
            if (iCount > 1)
            {
                strTop = "top " + iCount.ToString();
            }

            string sql = "select  " + strTop + "  * from [ShangPin]  ";
            SqlConnection con = new SqlConnection(SqlHelper.connstring);
            SqlCommand cmd = new SqlCommand(sql, con);

            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = null;
            try
            {
                con.Open();
                ds = new DataSet();
                da.Fill(ds);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }
            return ds;
        }
    }
}